package com.huaxin.device.models;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class BaseModel {

    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    @Schema(description = "唯一ID（UUID）- 主键", example = "1")
    private String id;

    @TableField(value = "auto_id")
    @Schema(description = "自增序列号（唯一索引，非主键）", example = "1")
    private Long autoId;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2021-01-01 00:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createdAt;

    @TableField(value = "created_by", fill = FieldFill.INSERT)
    @Schema(description = "创建人", example = "1")
    private String createdBy;

    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2021-01-01 00:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updatedAt;

    @TableField(value = "updated_by", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新人", example = "1")
    private String updatedBy;

    @TableLogic
    @TableField(value = "is_deleted")
    @Schema(description = "是否删除（0:未删, 1:已删）", example = "0")
    private Integer isDeleted = 0;

    @TableField(value = "deleted_at", fill = FieldFill.UPDATE)
    @Schema(description = "删除时间", example = "2021-01-01 00:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime deletedAt;

    @TableField(value = "deleted_by", fill = FieldFill.UPDATE)
    @Schema(description = "删除人", example = "1")
    private String deletedBy;

    @TableField(value = "org_id")
    @Schema(description = "组织ID", example = "org_001")
    private String orgId;
}
